package com.ruoyi.business.uitls;

import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;

/**
 * @Author: Long
 * @Description: TODO
 * @Date: 2024/9/13 15:10
 * @Version: 1.0
 */
public class RedisUtils {
    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    /**
     * 获取附近的商家,根据类型确定返回值,为了方便List返回值用的object
     *
     * @param latitude  纬度
     * @param longitude 经度
     * @return 集合对象
     */
//    public List<Long> getNearbyShops(double longitude, double latitude) {
//        RedisGeoCommands.GeoRadiusCommandArgs args = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeDistance().includeCoordinates();
//        GeoOperations<String, Object> geoOps = redisTemplate.opsForGeo();
//        // 获取附近50km以内的商家
//        GeoResults<RedisGeoCommands.GeoLocation<Object>> results = geoOps.radius("shops",
//                new Circle(new Point(longitude, latitude), new Distance(50, Metrics.KILOMETERS)), args);
//        // 处理结果集,将Map转换成List
//        return results.getContent().stream()
//                .map(result -> (Long)result.getContent().getName())
//                .collect(Collectors.toList());
//    }
}
